#ifndef _FOLDEDTORUS_HPP_
#define _FOLDEDTORUS_HPP_

#include "network.hpp"
#include "routefunc.hpp"

class FoldedTorus : public Network
{
public:
    FoldedTorus(const Configuration &config, const string & name);
    static void RegisterRoutingFunctions();
private:
    int inner_router_nubmers;
    int ports_per_inner_router;
    int side_router_nubmers;
    int ports_per_side_router;

    int mem_numbers;
    int mem_port_per_sidenode;

    vector<vector<int>> router_id;
    vector<int> side_nodes;
    vector<vector<int>> links_to_this_router;
    vector<vector<int>> links_from_this_router;
    vector<vector<vector<int>>> routing_table;

    void _ComputeSize(const Configuration &config);
    void _BuildNet(const Configuration &config);
};

void min_foldedtorus(const Router *r, const Flit *f, int in_channel, 
                     OutputSet *outputs, bool inject);

#endif